/*
 * Copyright (C) 2008,2009,2010,2011  Paulo Cesar Pereira de Andrade.
 *
 * This is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * Authors:
 *	Paulo Cesar Pereira de Andrade
 */

#ifndef _eemit_h
#define _eemit_h

#include "etypes.h"

/*
 * Types
 */
struct ecase {
    eint_t	 value;
#if JITVM
    eobject_t	 label;
#else
    eint32_t	 label;
#endif
};

struct evswitch {
    eint_t	 imin;
    eint_t	 imax;
    eint32_t	 mask;
#if JITVM
    eobject_t	 cases[1];
#else
    eint32_t	 cases[1];
#endif
};

struct ehswitch {
    eint_t	 imin;
    eint_t	 imax;
    eint32_t	 mask;
    ecase_t	*cases[1];
};

/*
 * Prototypes
 */
extern void
init_emit(void);

extern void
finish_emit(void);

extern void
eemit(efunction_t *function);

#if JITVM
extern void
esearch_instruction_pointer(void);

extern ebool_t
ejit_pointer_p(eobject_t value);

/*
 * Externs
 */
extern eobject_t	 ethread_exit_code;
extern ehash_t		*eswitch_hash;
#endif

#endif /* _eemit_h */
